<template>
	<view>
		<view class="" style="width: 90%;margin: 0px auto;margin-top: 40rpx;">
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[4]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						患者手机号：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.mobile" placeholder="请输入手机号" />
				</view>
			</view>
			<view class="xian"></view>
		
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[1]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						患者姓名：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.nickname" placeholder="请输入患者真实姓名" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[0]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						患者性别：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<radio-group @change="radioChange">
						<label class="radio">
							<radio value="1" :checked="form_info.gender == 1" /> <text
								style="margin-left: 10rpx;">男</text>
						</label>
						<label class="radio" style="margin-left: 10rpx;">
							<radio value="2" :checked="form_info.gender == 2" /> <text
								style="margin-left: 10rpx;">女</text>
						</label>
					</radio-group>
					<!-- <input type="text" placeholder="请输入手机号" /> -->
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[2]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						患者年龄：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.age" placeholder="请输入患者年龄" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[2]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						身份证号码：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.card_id" placeholder="请输入身份证号" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[2]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						身高：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.hz_height" placeholder="请输入身高" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[2]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						体重：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.hz_weight" placeholder="请输入体重" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[2]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						紧急联系人：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.emergency_contact" placeholder="请输入紧急联系人姓名" />
				</view>
			</view>
			<view class="xian"></view>
			<view class="fl" style="justify-content: space-between;align-items: center;">
				<view class="fl" style="width: 40%;">
					<view class="">
						<image :src="url+imglist[2]" mode="" class="tb"></image>
					</view>
					<view class="title" style="">
						紧急联系号码：
					</view>
				</view>
				<view class="" style="width: 60%;">
					<input type="text" v-model="form_info.emergency_contact_tel" placeholder="请输入紧急联系人号码" />
				</view>
			</view>
			
			
			
			<!-- <view class="xian"></view> -->
		</view>
		<view class="btns" @click="save_userinfo()">
			保存并提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				imglist: [
					'wechatimg/xb.png',
					'wechatimg/xm.png',
					'wechatimg/nl.png',
					'wechatimg/yh.png',
					'wechatimg/sj.png',
				],
				form_info: {},
			}
		},
		onShow() {
			this.getdata()
		},
		methods: {
			save_userinfo(){
				var that = this
				let params = {
					nickname:that.form_info.nickname,
					mobile:that.form_info.mobile,
					gender:that.form_info.gender,
					age:that.form_info.age,
					card_id:that.form_info.card_id,
					hz_height:that.form_info.hz_height,
					hz_weight:that.form_info.hz_weight,
					emergency_contact:that.form_info.emergency_contact,
					emergency_contact_tel:that.form_info.emergency_contact_tel,
				}
				uni.request({
					url: that.global.url + 'api/user/hz_center_save',
					method: 'POST',
					header:{'token':uni.getStorageSync('hz_token')},
					data: params,
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							// 存用户信息
							uni.showToast({
								title:'修改成功'
							})
							setTimeout(()=>{
								uni.navigateBack()
							},1000)
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'none'
							})
						}
					},
					complete() {
						// uni.hideLoading()
					}
				})
			},
			getdata(){
				var that = this
				uni.request({
					url: that.global.url + 'api/user/hz_center',
					method: 'POST',
					header:{'token':uni.getStorageSync('hz_token')},
					data: {
						
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							// 存用户信息
							that.form_info = result.data
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'none'
							})
						}
					},
					complete() {
						// uni.hideLoading()
					}
				})
			},
			radioChange(e) {
				console.log(e)
				this.form_info.gender = e.detail.value
			},
		}
	}
</script>

<style>
.fl {
		display: flex;
	}

	.tb {
		width: 38rpx;
		height: 40rpx
	}

	.xian {
		border-bottom: 1px solid #e5e5e5;
		width: 100%;
		margin-top: 25rpx;
		margin-bottom: 25rpx;
	}

	.title {
		margin-left: 20rpx;
		width: 300rpx;
		font-weight: bold;
		font-size: 30rpx;
	}

	.left-item {
		width: 100%;
		height: 50px;
		background: #e5e5e5;
		text-align: center;
		line-height: 50px;
	}

	.choice {
		width: 100%;
		height: 50px;
		background: #fff;
		text-align: center;
		line-height: 50px;
	}

	.cc {
		width: 82%;
		margin: 0px auto;
		margin-top: 20rpx;
		padding: 21rpx;
		border: 1px solid #ccc;
		border-radius: 10rpx;
		box-shadow: 1px 1px 4px 1px #ccc;
	}

	.bt {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		font-size: 24rpx;
		color: #b5b5b5;
		margin-top: 10rpx;
	}

	.jj {
		padding: 5rpx 15rpx;
		font-size: 30rpx;
		color: #000;
		background-color: #e5e5e5;
		margin: 0px 3px 0px 3px;

	}

	.sub_box {
		background-color: #fff;
		position: fixed;
		bottom: 0px;
		height: 150rpx;
		left: 0px;
		right: 0px;
		border-top: 1px solid #ccc;
	}

	.sub_btn {
		background-color: #00c500;
		color: #fff;
		width: 90%;
		margin: 0px auto;
		padding: 20rpx;
		border-radius: 10rpx;
		text-align: center;
		margin-top: 20rpx
	}
	.btns{
		width: 85%;
		text-align: center;
		padding: 20rpx;
		margin: 0px auto;
		position: fixed;
		bottom: 20px;
		left: 4%;
		background-color: #1262DB;
		color: #fff;
	}
</style>
